<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('order_items', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('order_id');
            $table->string('type')->default(\App\Enums\OrderItemType::Goods)->comment('item的类型');
            $table->bigInteger('goods_id')->nullable();
            $table->bigInteger('cost_rule_id')->nullable();
            $table->bigInteger('table_id')->nullable();
            $table->bigInteger('assistant_user_id')->nullable();
            $table->integer('count')->default(1)->comment('数量');
            $table->decimal('money', 10, 2)->default(0)->comment('金额');
            $table->decimal('discount_money', 10, 2)->default(0)->comment('折扣金额');
            $table->decimal('origin_money', 10, 2)->default(0)->comment('原价');
            $table->timestamp('start_at')->nullable();
            $table->timestamp('end_at')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('order_items');
    }
};
